<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@  taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html lang="en">
<%@ include file="common/head.jsp"%>

<body class="fix-header fix-sidebar">

	<!-- Preloader - style you can find in spinners.css -->
	<div class="preloader">
		<svg class="circular" viewBox="25 25 50 50">
				<circle class="path" cx="50" cy="50" r="20" fill="none"
				stroke-width="2" stroke-miterlimit="10" /> </svg>
	</div>
	<!-- Main wrapper  -->
	<div id="main-wrapper">
		<!-- header header  -->
		<%@ include file="common/header.jsp"%>
		<!-- End header header -->
		<!-- Left Sidebar  -->
		<%@ include file="common/nav.jsp"%>
		<!-- End Left Sidebar  -->
		<!-- Page wrapper  -->
		<div class="page-wrapper">
			<!-- 锐高软件 -->
			 <%@ include file="../common/ruigao.jsp" %>
		
			<!--
                    	作者：offline
                    	时间：2018-03-26
                    	描述：添加员工信息
                    -->
			<div class="container-fluid">
						<!-- Start Page Content -->
						<div class="row justify-content-center">
							<div class="col-lg-12">
								<div class="card">
									<div class="card-body">
										<div class="card-content">
											<!-- Left sidebar -->
											<div class="inbox-leftbar">

												<a href="${pageContext.request.contextPath}/userServlet" class="btn btn-danger btn-block waves-effect waves-light">
													<font style="vertical-align: inherit;">
														<font style="vertical-align: inherit;">员工查看</font>
													</font>
												</a>
											</div>
											<!-- End Left sidebar -->
											<div class="inbox-rightbar">
												<div class="" role="toolbar">
													<div class="btn-group">
														<button type="button" class="btn btn-light waves-effect"><i class="mdi mdi-archive font-18 vertical-middle"></i></button>
														<button type="button" class="btn btn-light waves-effect"><i class="mdi mdi-alert-octagon font-18 vertical-middle"></i></button>
														<button type="button" class="btn btn-light waves-effect"><i class="mdi mdi-delete-variant font-18 vertical-middle"></i></button>
													</div>

								

												</div>
											</div>
										</div>
									</div>
								
									
									<div class="form-validation">
										<form class="form-valide col-lg-8" id="form" method="post" novalidate="novalidate" style="margin: 0 auto;">
											
											<div class="form-group row">
												<label class="col-lg-2 col-form-label" for="val-username">姓名 <span class="text-danger">*</span></label>
												<div class="col-lg-10">
													<input type="text" class="form-control" id="val-username" name="val-username" placeholder="输入姓名">
												</div>
											</div>
											
											
											
											<div class="form-group row">
												<label class="col-lg-2 col-form-label" for="val-loginname">登陆名 <span class="text-danger">*</span></label>
												<div class="col-lg-10">
													<input type="text" class="form-control" id="val-loginname" name="val-loginname" placeholder="输入登陆名">
												</div>
											</div>
											<div class="form-group row">
												<label class="col-lg-2 col-form-label" for="val-loginpwd">密码 <span class="text-danger">*</span></label>
												<div class="col-lg-10">
													<input type="password" class="form-control" id="val-loginpwd" name="val-loginpwd" placeholder="输入密码">
												</div>
											</div>
											
											<div class="form-group row">
												<label class="col-lg-2 col-form-label" for="val-email">邮箱 <span class="text-danger">*</span></label>
												<div class="col-lg-10">
													<input type="text" class="form-control" id="val-email" name="val-email" placeholder="输入邮箱">
												</div>
											</div>
											<div class="form-group row">
												<label class="col-lg-2 col-form-label" for="val-password">性别<span class="text-danger">*</span></label>
												<div class="col-lg-10">
													<select class="form-control" id="val-sex" name="val-sex">
														
														<option value="1">男</option>
														<option value="2">女</option>

													</select>
												</div>
											</div>
											<div class="form-group row">
												<label class="col-lg-2 col-form-label" for="val-phone">手机号 <span class="text-danger">*</span></label>
												<div class="col-lg-10">
													<input type="text" class="form-control" id="val-phone" name="val-phone" placeholder="输入手机号">
												</div>
											</div>
											<div class="form-group row">
												<label class="col-lg-2 col-form-label" for="val-suggestions">地址 <span class="text-danger">*</span></label>
												<div class="col-lg-10">
													<textarea class="form-control" id="val-suggestions" name="val-suggestions" rows="5" placeholder="输入地址"></textarea>
												</div>
											</div>
										
											<div class="form-group row">
												<label class="col-lg-2 col-form-label" for="val-currency">身份证号 <span class="text-danger">*</span></label>
												<div class="col-lg-10">
													<input type="text" class="form-control" id="val-currency" name="val-currency" placeholder="输入身份号">
												</div>
											</div>
											<div class="form-group row">
												<label class="col-lg-2 col-form-label" for="val-phone">家属联系方式 <span class="text-danger">*</span></label>
												<div class="col-lg-10">
													<input type="text" class="form-control" id="val-familyphone" name="val-familyphone" placeholder="输入号码">
												</div>
											</div>
											<div class="form-group row">
												<label class="col-lg-2 col-form-label" for="val-number">出身年月<span class="text-danger">*</span></label>
												<div class="col-lg-10">
													<input type="date" class="form-control" name="val-date" placeholder="dd/mm/yyyy">
												</div>
											</div>
											<div class="form-group row">
												<label class="col-lg-2 col-form-label" for="val-phoneus">学历 <span class="text-danger">*</span></label>
												<div class="col-lg-10">
													<select class="form-control" id="val-diploma" name="val-diploma">
														<option value="初中">初中</option>
														<option value="高中">高中</option>
														<option value="大专">大专</option>
														<option value="本科">本科</option>
                                                        <option value="博士">博士</option>
													</select>
												</div>
											</div>
												<div class="form-group row">
												<label class="col-lg-2 col-form-label" for="val-digits">职位 <span class="text-danger">*</span></label>
												<div class="col-lg-10">
													<select class="form-control" id="val-digits" name="val-digits">
														<option value="员工">员工</option>
														<option value="经理">经理</option>
														
														
													</select>
												</div>
											</div>
											    <%@ include file="../listall/selectcompanyname.jsp" %>
                                            
										  <div class="form-group row">
												<label class="col-lg-2 col-form-label" for="val-skill">所属部门 <span class="text-danger">*</span></label>
												<div class="col-lg-10">
													<select class="form-control" id="val-dept" name="val-dept">
													    
														
														
													</select>
												</div>
											</div>						
                                            	<div class="form-group row">
												<div class="col-lg-8 ml-auto">
													<button type="button" class="btn btn-success btn sweet-tijiao ">提交</button>
													<button type="reset" class="btn btn-primary ">重置</button>
												     <input type="hidden" id="useradd" name="opt" value="">
												</div>    
											</div>
										</form>
									</div>
								</div>
							</div>
						</div>
						<!-- End PAge Content -->
						
			 </div>
		</div>
	</div>
	
	<!-- End Container fluid  -->
	<!-- footer -->
	<%@ include file="common/footer.jsp"%>
	<!-- End footer -->
	<!-- End Page wrapper  -->
	<%@ include file="common/js.jsp"%>
    <script type="text/javascript">
    $(function(){
    	var options = $("#val-company option:selected");
		var companyid= parseInt(options.val());
		var companyname = options.text();		
		var selectcompanyopt=$("#opt").val("selectcompanyid");
		 $.ajax({
 	    	url:"companyid",
 	    	data:{"companyid":companyid},
 	    	type:"GET",
 	    	dataType:"json",
 	    	success:function(data){
 	        	$("#val-dept").text("");
 	        	for(var i in data){
 	       			$("#val-dept").append("<option value="+data[i].deptId+">"+data[i].deptName+"</option>");
 	        	}
 	    	},
 	    	error:function(data){
 	    		 swal({
			            title:'操作失败！',		           
			            type:'error',
			            confirmButtonText:'确定',
			            closeOnConfirm:false
			         });
 	    	}
 	    });
 		
		
		
          //获取选择的公司
    	$("#val-company").change(function(){
    		var options = $("#val-company option:selected");
    		var companyid= parseInt(options.val());
    		var companyname = options.text();		
    		var selectcompanyopt=$("#opt").val("selectcompanyid");
    	    $.ajax({
    	    	url:"companyid",
    	    	data:{"companyid":companyid},
    	    	type:"GET",
    	    	dataType:"json",
    	    	success:function(data){
    	        	$("#val-dept").text("");
    	        	for(var i in data){
    	       			$("#val-dept").append("<option value="+data[i].deptId+">"+data[i].deptName+"</option>");
    	        	}
    	    	},
    	    	error:function(data){
    	    		 swal({
 			            title:'操作失败！',		           
 			            type:'error',
 			            confirmButtonText:'确定',
 			            closeOnConfirm:false
 			         });
    	    	}
    	    });
    		
    		
    		
       	 
    	});
           //添加事件
           $(".btn-success").click(function(){
        	   $("#useradd").val("useradd");
        	   
        	   $.ajax({
        		   url:"userServlet",
        		   data:$("#form").serialize(),
        		   datatype:"json",
        		   type:"GET",    		  
        		   success:function(data){
        			   if(data){
 						  swal(
 								{
 										title : "添加成功!",
 										type:'success',
 										 text: "是否返回列表查看？", 
 										showCancelButton : true,
 										closeOnConfirm : false,
 										cancelButtonText : "取消",
 										confirmButtonText : "确定"
 									},
 									function(inputValue) {
 										if (inputValue === true){
 									     location.href="${pageContext.request.contextPath}/userServlet";
 										}else{
 											return false;
 										}
 									});						 			 			
 				        }
        		   },error:function(data){
        			   swal({
   			            title:'添加失败！',		           
   			            type:'error',
   			            confirmButtonText:'确定',
   			            closeOnConfirm:false
   			         });
        		   }
        	   });
        	   
           });
          
    });
    </script>
</body>

</html>